import axios from "../api"; // 导入接口配置
import Cookies from "js-cookie";
/**
 * 获取key
 * @param params
 * @returns
 */
export const GetToken = async () => {
  const res: any = await axios.post("Common/GetToken", {
    Param: Cookies.get("token"),
  });
  if (res.Tag === 1) {
    Cookies.set("tk", res.Data);
  } else {
    Cookies.remove("tk");
  }
};
/**
 * 登录
 * @param params
 * @returns
 */
export const LoginByPwd = async (params: any) => {
  return await axios.post("Member/LoginByPwd", params);
};
/**
 * @description: 查询首页
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetPageIndexInfo = async (params: any) => {
  return await axios.post("Banner/GetPageIndexInfo", params);
};
/**
 * GetBanner
 * @param params
 * @returns
 */
export const GetBanner = async (params: any) => {
  return await axios.post("Banner/GetBanner", params);
};
/**
 * @description: 文件上传
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const UploadFile = async (params: any) => {
  return await axios.post("File/UploadFile", params);
};

/**
 * @description: 编辑首页下部分信息
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const EidtPageIndexInfo = async (params: any) => {
  await GetToken();
  return await axios.post("Banner/EidtPageIndexInfo", params);
};
/**
 * @description: banner上传
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const InsertBanner = async (params: any) => {
  await GetToken();
  return await axios.post("Banner/InsertBanner", params);
};

/**
 * @description: 夏季编辑
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const EidtSummer = async (params: any) => {
  await GetToken();
  return await axios.post("Summer/EidtSummer", params);
};
/**
 * @description: 查询夏季
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetSummer = async (params: any) => {
  return await axios.post("Summer/GetSummer", params);
};

/**
 * @description: 查询寝具信息
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetBeddingData = async (params: any) => {
  return await axios.post("Banner/GetBeddingData", params);
};
/**
 * @description: 商品编辑新增与修改
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const EditGoods = async (params: any) => {
  await GetToken();
  return await axios.post("Goods/EditGoods", params);
};

/**
 * @description: 新增类别
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const InsertGoodsType = async (params: any) => {
  await GetToken();
  return await axios.post("GoodsType/InsertGoodsType", params);
};

/**
 * @description: 修改类别
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const UpdateGoodsType = async (params: any) => {
  await GetToken();
  return await axios.post("GoodsType/UpdateGoodsType", params);
};

/**
 * @description: 删除类别
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const DeleteGoodsType = async (params: any) => {
  await GetToken();
  return await axios.post("GoodsType/DeleteGoodsType", params);
};

/**
 * @description: 删除商品
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const DeleteGoods = async (params: any) => {
  await GetToken();
  return await axios.post("Goods/DeleteGoods", params);
};

/**
 * @description: 查询商品
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetGoodsByCondition = async (params: any) => {
  return await axios.post("Goods/GetGoodsByCondition", params);
};

/**
 * @description: 设置精选商品
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const RecommendGoods = async (params: any) => {
  await GetToken();
  return await axios.post("Goods/RecommendGoods", params);
};

/**
 * @description: 商品详情
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetGoodsDetail = async (params: any) => {
  return await axios.post("Goods/GetGoodsDetail", params);
};

/**
 * @description: 睡眠学院详情页
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const EditSleep = async (params: any) => {
  await GetToken();
  return await axios.post("Sleep/EditSleep", params);
};

/**
 * @description: 责任
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const EidtResponsibility = async (params: any) => {
  await GetToken();
  return await axios.post("Responsibility/EidtResponsibility", params);
};
/**
 * @description: 责任
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetSleep = async (params: any) => {
  return await axios.post("Sleep/GetSleep", params);
};
/**
 * @description: 责任
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetResponsibility = async (params: any) => {
  return await axios.post("Responsibility/GetResponsibility", params);
};

/**
 * @description: 睡眠上半部分
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const GetSleepPageData = async (params: any) => {
  return await axios.post("Sleep/GetSleepPageData", params);
};

/**
 * @description: 睡眠上半部分保存
 * @param {any} params
 * @return {*}
 * @author: cool panda
 */
export const EditSleepPageData = async (params: any) => {
  await GetToken();
  return await axios.post("Sleep/EditSleepPageData", params);
};

export const GetSleepType = async (params: any) => {
  return await axios.post("SleepType/GetSleepType", params);
};

export const UpdateSleepType = async (params: any) => {
  await GetToken();
  return await axios.post("SleepType/UpdateSleepType", params);
};

export const DeleteSleepType = async (params: any) => {
  await GetToken();
  return await axios.post("SleepType/DeleteSleepType", params);
};

export const InsertSleepType = async (params: any) => {
  await GetToken();
  return await axios.post("SleepType/InsertSleepType", params);
};

export const GetSleepDetail = async (params: any) => {
  return await axios.post("Sleep/GetSleepDetail", params);
};

export const DeleteSleep = async (params: any) => {
  await GetToken();
  return await axios.post("Sleep/DeleteSleep", params);
};
export const EidtCommercialCustomer = async (params: any) => {
  await GetToken();
  return await axios.post("CommercialCustomer/EidtCommercialCustomer", params);
};

export const GetCommercialCustomer = async (params: any) => {
  return await axios.post("CommercialCustomer/GetCommercialCustomer", params);
};

export const GetAb = async (params: any) => {
  return await axios.post("Ab/GetAb", params);
};

export const EidtAb = async (params: any) => {
  await GetToken();
  return await axios.post("Ab/EidtAb", params);
};

export const GetRandomGoods = async (params: any) => {
  return await axios.post("Goods/GetRandomGoods", params);
};
